<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE root PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">

	<h:outputText rendered="#{equipamentoBean.saveState}">
		<div class="innerTitle">Cadastro de Equipamento</div>
	</h:outputText>

	<h:outputText rendered="#{equipamentoBean.updateState}">
		<div class="innerTitle">Atualização de Equipamento</div>
	</h:outputText>

	<h:inputHidden value="#{equipamentoBean.entity.id}" rendered="#{equipamentoBean.updateState}"/>

	<rich:tabPanel switchType="client">

		<rich:tab label="Cadastro">

			<h:panelGrid columns="6" styleClass="crud" columnClasses="label">

				<h:outputLabel value="Nome :"/>
				<h:inputText id="descricaoEquipamento" value="#{equipamentoBean.entity.descricao}" required="true" maxlength="50" size="50">
					<f:validateLength maximum="50"/>
					<rich:ajaxValidator event="onblur"/>
				</h:inputText>
				<rich:message errorClass="error" for="descricaoEquipamento"/>

				<h:outputLabel value="Número de Serie :"/>
				<h:inputText id="numeroSerie" value="#{equipamentoBean.entity.numeroSerie}" required="true" maxlength="8" size="10">
					<f:validateLength maximum="8"/>
					<rich:ajaxValidator event="onblur"/>
				</h:inputText>
				<rich:message errorClass="error" for="numeroSerie"/>

				<h:outputLabel value="Número Serial:"/>
				<h:inputText id="numeroSerial" value="#{equipamentoBean.entity.numeroSerial}" required="true" maxlength="8" size="10">
					<f:validateLength maximum="8"/>
					<rich:ajaxValidator event="onblur"/>
				</h:inputText>
				<rich:message errorClass="error" for="numeroSerial"/>

				<h:outputLabel value="Número Firmware:" />
				<h:inputText id="numeroFirmware" value="#{equipamentoBean.entity.numeroFirmware}" required="ture" maxlength="8" size="10">
					<f:validateLength maximum="8"/>
					<rich:ajaxValidator event="onblur"/>
					<f:convertNumber minIntegerDigits="1" minFractionDigits="1" maxFractionDigits="2" />
				</h:inputText>
				<rich:message errorClass="error" for="numeroFirmware" />

				<h:outputLabel value="Comodato:"/>
				<h:selectOneMenu value="#{equipamentoBean.entity.tipoEquipamento}" styleClass="tipoEquipamento">
					<f:selectItems value="#{equipamentoBean.listaTipoEquipamento}" />
				</h:selectOneMenu><br/>

				<h:outputLabel value="Número de Portas :"/>
				<h:inputText id="numeroPortas" value="#{equipamentoBean.entity.numeroPortas}" required="true" maxlength="2" size="2">
					<f:validateLength maximum="2"/>
					<rich:ajaxValidator event="onblur"/>
				</h:inputText>
				<rich:message errorClass="error" for="numeroPortas"/>

				<h:outputLabel value="Fabricante :"/>
				<h:selectOneMenu id="fabricanteEquipamento" value="#{equipamentoBean.entity.fabricante.id}">
	  				<f:selectItems value="#{fabricanteBean.listaFabricantes}"/>
				</h:selectOneMenu>
				<rich:message for="fabricanteEquipamento"/>

				<h:outputLabel value="Chip :"/>
				<h:selectOneMenu id="chipEquipamento" value="#{equipamentoBean.entity.chip.id}">
	  				<f:selectItems value="#{chipBean.listaChips}"/>
				</h:selectOneMenu>
				<rich:message for="chipEquipamento"/>

				<h:outputLabel value="Data Compra :"/>
				<rich:calendar id="dataCompraSerial" value="#{equipamentoBean.entity.dataCompra}" required="true" datePattern="dd/MM/yyyy"/>
				<rich:message errorClass="error" for="dataCompraSerial"/>

				<h:outputLabel value="Data Garantia :"/>
				<rich:calendar id="dataGarantia" value="#{equipamentoBean.entity.dataGarantia}" required="true" datePattern="dd/MM/yyyy"/>
				<rich:message errorClass="error" for="dataGarantia"/>

				<h:outputLabel value="Tipo Equipamento:"/>
				<h:selectOneMenu value="#{equipamentoBean.entity.seqTipoEquipamento}" styleClass="seqTipoEquipamento">
					<f:selectItems value="#{equipamentoBean.listaSeqTipoEquipamento}" />
				</h:selectOneMenu><br/>


			</h:panelGrid>

		</rich:tab>

	</rich:tabPanel>

	<br/>

	<a4j:commandButton value="Inserir" type="submit" action="#{equipamentoBean.save}" styleClass="button" rendered="#{equipamentoBean.saveState}" reRender="popup"/>
	<a4j:commandButton value="Atualizar" type="submit" action="#{equipamentoBean.update}" styleClass="button" rendered="#{equipamentoBean.updateState}"  reRender="popup"/>
	<a4j:commandButton value="Voltar" type="submit" action="#{equipamentoBean.search}" styleClass="button" immediate="true"  reRender="popup"/>

</ui:composition>